package se.thoka.twt.client.event;

import se.thoka.twt.shared.item.DatastoreChangeType;

import com.google.gwt.event.shared.GwtEvent;

public class DatastoreChangedEvent<T> extends GwtEvent<DatastoreChangedHandler<T>> {
	
	public static Type<DatastoreChangedHandler<?>> TYPE = new Type<DatastoreChangedHandler<?>>();
	
	private final DatastoreChangeType changeType;
	
	public DatastoreChangedEvent(DatastoreChangeType change) {
		this.changeType = change;
	}
	
	public DatastoreChangeType getChangeType() {
		return changeType;
	}

	@SuppressWarnings({ "rawtypes", "unchecked" })
	@Override
	public Type<DatastoreChangedHandler<T>> getAssociatedType() {
		return (Type) TYPE;
	}

	@Override
	protected void dispatch(DatastoreChangedHandler<T> handler) {
		handler.onDatastoreChanged(this);
	}

}
